package com.xdkj.commons.util;

import lombok.Data;

/**
 * ClassName BaseResponse
 * Description:
 *
 * @Author:一尘
 * @Version:1.0
 * @Date:2021-11-02-10:25
 */
@Data
public class BaseResponse {
    /**
     * 状态码
     */
    private Integer code;
    /**
     * 消息
     */
    private String message;
    /**
     * 数据
     */
    private Object data;
    /**
     * 总数
     */
    private Integer count;

    public static BaseResponse ok() {
        BaseResponse bn = new BaseResponse();
        bn.setCode(2000);
        bn.setMessage(null);
        bn.setData(null);
        return bn;
    }

    public static BaseResponse ok(int code) {
        BaseResponse bn = new BaseResponse();
        bn.setCode(code);
        bn.setMessage(null);
        bn.setData(null);
        return bn;
    }

    public static BaseResponse ok(int code, String message) {
        BaseResponse bn = new BaseResponse();
        bn.setCode(code);
        bn.setMessage(message);
        bn.setData(null);
        return bn;
    }

    public static BaseResponse ok(int code, Object data) {
        BaseResponse bn = new BaseResponse();
        bn.setCode(code);
        bn.setMessage(null);
        bn.setData(data);
        return bn;
    }

    public static BaseResponse ok(int code, String message, Object data) {
        BaseResponse bn = new BaseResponse();
        bn.setCode(code);
        bn.setMessage(message);
        bn.setData(data);
        return bn;
    }

    public static BaseResponse error() {
        BaseResponse bn = new BaseResponse();
        bn.setCode(2000);
        bn.setMessage(null);
        bn.setData(null);
        return bn;
    }

    public static BaseResponse error(int code) {
        BaseResponse bn = new BaseResponse();
        bn.setCode(code);
        bn.setMessage(null);
        bn.setData(null);
        return bn;
    }

    public static BaseResponse error(int code, String message) {
        BaseResponse bn = new BaseResponse();
        bn.setCode(code);
        bn.setMessage(message);
        bn.setData(null);
        return bn;
    }

    public static BaseResponse error(int code, Object data) {
        BaseResponse bn = new BaseResponse();
        bn.setCode(code);
        bn.setMessage(null);
        bn.setData(data);
        return bn;
    }

    public static BaseResponse error(int code, String message, Object data) {
        BaseResponse bn = new BaseResponse();
        bn.setCode(code);
        bn.setMessage(message);
        bn.setData(data);
        return bn;
    }
}
